#ifndef THINK_THINK_REQUEST_H
#define THINK_THINK_REQUEST_H

static char* think_request =
	"\n"
	"// +----------------------------------------------------------------------\n"
	"// | ThinkPHP [ WE CAN DO IT JUST THINK ]\n"
	"// +----------------------------------------------------------------------\n"
	"// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.\n"
	"// +----------------------------------------------------------------------\n"
	"// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )\n"
	"// +----------------------------------------------------------------------\n"
	"// | Author: liu21st <liu21st@gmail.com>\n"
	"// +----------------------------------------------------------------------\n"
	"\n"
	"namespace think;\n"
	"\n"
	"class Request\n"
	"{\n"
	"    /**\n"
	"     * @var object 对象实例\n"
	"     */\n"
	"    protected static $instance;\n"
	"\n"
	"    protected $method;\n"
	"    /**\n"
	"     * @var string 域名（含协议和端口）\n"
	"     */\n"
	"    protected $domain;\n"
	"\n"
	"    /**\n"
	"     * @var string URL地址\n"
	"     */\n"
	"    protected $url;\n"
	"\n"
	"    /**\n"
	"     * @var string 基础URL\n"
	"     */\n"
	"    protected $baseUrl;\n"
	"\n"
	"    /**\n"
	"     * @var string 当前执行的文件\n"
	"     */\n"
	"    protected $baseFile;\n"
	"\n"
	"    /**\n"
	"     * @var string 访问的ROOT地址\n"
	"     */\n"
	"    protected $root;\n"
	"\n"
	"    /**\n"
	"     * @var string pathinfo\n"
	"     */\n"
	"    protected $pathinfo;\n"
	"\n"
	"    /**\n"
	"     * @var string pathinfo（不含后缀）\n"
	"     */\n"
	"    protected $path;\n"
	"\n"
	"    /**\n"
	"     * @var array 当前路由信息\n"
	"     */\n"
	"    protected $routeInfo = [];\n"
	"\n"
	"    /**\n"
	"     * @var array 环境变量\n"
	"     */\n"
	"    protected $env;\n"
	"\n"
	"    /**\n"
	"     * @var array 当前调度信息\n"
	"     */\n"
	"    protected $dispatch = [];\n"
	"    protected $module;\n"
	"    protected $controller;\n"
	"    protected $action;\n"
	"    // 当前语言集\n"
	"    protected $langset;\n"
	"\n"
	"    /**\n"
	"     * @var array 请求参数\n"
	"     */\n"
	"    protected $param   = [];\n"
	"    protected $get     = [];\n"
	"    protected $post    = [];\n"
	"    protected $request = [];\n"
	"    protected $route   = [];\n"
	"    protected $put;\n"
	"    protected $session = [];\n"
	"    protected $file    = [];\n"
	"    protected $cookie  = [];\n"
	"    protected $server  = [];\n"
	"    protected $header  = [];\n"
	"\n"
	"    /**\n"
	"     * @var array 资源类型\n"
	"     */\n"
	"    protected $mimeType = [\n"
	"        \'xml\'   => \'application/xml,text/xml,application/x-xml\',\n"
	"        \'json\'  => \'application/json,text/x-json,application/jsonrequest,text/json\',\n"
	"        \'js\'    => \'text/javascript,application/javascript,application/x-javascript\',\n"
	"        \'css\'   => \'text/css\',\n"
	"        \'rss\'   => \'application/rss+xml\',\n"
	"        \'yaml\'  => \'application/x-yaml,text/yaml\',\n"
	"        \'atom\'  => \'application/atom+xml\',\n"
	"        \'pdf\'   => \'application/pdf\',\n"
	"        \'text\'  => \'text/plain\',\n"
	"        \'image\' => \'image/png,image/jpg,image/jpeg,image/pjpeg,image/gif,image/webp,image/*\',\n"
	"        \'csv\'   => \'text/csv\',\n"
	"        \'html\'  => \'text/html,application/xhtml+xml,*/*\',\n"
	"    ];\n"
	"\n"
	"    protected $content;\n"
	"\n"
	"    // 全局过滤规则\n"
	"    protected $filter;\n"
	"    // Hook扩展方法\n"
	"    protected static $hook = [];\n"
	"    // 绑定的属性\n"
	"    protected $bind = [];\n"
	"    // php://input\n"
	"    protected $input;\n"
	"    // 请求缓存\n"
	"    protected $cache;\n"
	"    // 缓存是否检查\n"
	"    protected $isCheckCache;\n"
	"    /**\n"
	"     * 是否合并Param\n"
	"     * @var bool\n"
	"     */\n"
	"    protected $mergeParam = false;\n"
	"\n"
	"    /**\n"
	"     * 构造函数\n"
	"     * @access protected\n"
	"     * @param array $options 参数\n"
	"     */\n"
	"    protected function __construct($options = [])\n"
	"    {\n"
	"        foreach ($options as $name => $item) {\n"
	"            if (property_exists($this, $name)) {\n"
	"                $this->$name = $item;\n"
	"            }\n"
	"        }\n"
	"        if (is_null($this->filter)) {\n"
	"            $this->filter = Config::get(\'default_filter\');\n"
	"        }\n"
	"\n"
	"        // 保存 php://input\n"
	"        $this->input = file_get_contents(\'php://input\');\n"
	"    }\n"
	"\n"
	"    public function __call($method, $args)\n"
	"    {\n"
	"        if (array_key_exists($method, self::$hook)) {\n"
	"            array_unshift($args, $this);\n"
	"            return call_user_func_array(self::$hook[$method], $args);\n"
	"        } else {\n"
	"            throw new Exception(\'method not exists:\' . __CLASS__ . \'->\' . $method);\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * Hook 方法注入\n"
	"     * @access public\n"
	"     * @param string|array $method   方法名\n"
	"     * @param mixed        $callback callable\n"
	"     * @return void\n"
	"     */\n"
	"    public static function hook($method, $callback = null)\n"
	"    {\n"
	"        if (is_array($method)) {\n"
	"            self::$hook = array_merge(self::$hook, $method);\n"
	"        } else {\n"
	"            self::$hook[$method] = $callback;\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 初始化\n"
	"     * @access public\n"
	"     * @param array $options 参数\n"
	"     * @return \\think\\Request\n"
	"     */\n"
	"    public static function instance($options = [])\n"
	"    {\n"
	"        if (is_null(self::$instance)) {\n"
	"            self::$instance = new static($options);\n"
	"        }\n"
	"        return self::$instance;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 销毁当前请求对象\n"
	"     * @access public\n"
	"     * @return void\n"
	"     */\n"
	"    public static function destroy()\n"
	"    {\n"
	"        if (!is_null(self::$instance)) {\n"
	"            self::$instance = null;\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 创建一个URL请求\n"
	"     * @access public\n"
	"     * @param string $uri    URL地址\n"
	"     * @param string $method 请求类型\n"
	"     * @param array  $params 请求参数\n"
	"     * @param array  $cookie\n"
	"     * @param array  $files\n"
	"     * @param array  $server\n"
	"     * @param string $content\n"
	"     * @return \\think\\Request\n"
	"     */\n"
	"    public static function create($uri, $method = \'GET\', $params = [], $cookie = [], $files = [], $server = [], $content = null)\n"
	"    {\n"
	"        $server[\'PATH_INFO\']      = \'\';\n"
	"        $server[\'REQUEST_METHOD\'] = strtoupper($method);\n"
	"        $info                     = parse_url($uri);\n"
	"        if (isset($info[\'host\'])) {\n"
	"            $server[\'SERVER_NAME\'] = $info[\'host\'];\n"
	"            $server[\'HTTP_HOST\']   = $info[\'host\'];\n"
	"        }\n"
	"        if (isset($info[\'scheme\'])) {\n"
	"            if (\'https\' === $info[\'scheme\']) {\n"
	"                $server[\'HTTPS\']       = \'on\';\n"
	"                $server[\'SERVER_PORT\'] = 443;\n"
	"            } else {\n"
	"                unset($server[\'HTTPS\']);\n"
	"                $server[\'SERVER_PORT\'] = 80;\n"
	"            }\n"
	"        }\n"
	"        if (isset($info[\'port\'])) {\n"
	"            $server[\'SERVER_PORT\'] = $info[\'port\'];\n"
	"            $server[\'HTTP_HOST\']   = $server[\'HTTP_HOST\'] . \':\' . $info[\'port\'];\n"
	"        }\n"
	"        if (isset($info[\'user\'])) {\n"
	"            $server[\'PHP_AUTH_USER\'] = $info[\'user\'];\n"
	"        }\n"
	"        if (isset($info[\'pass\'])) {\n"
	"            $server[\'PHP_AUTH_PW\'] = $info[\'pass\'];\n"
	"        }\n"
	"        if (!isset($info[\'path\'])) {\n"
	"            $info[\'path\'] = \'/\';\n"
	"        }\n"
	"        $options                      = [];\n"
	"        $options[strtolower($method)] = $params;\n"
	"        $queryString                  = \'\';\n"
	"        if (isset($info[\'query\'])) {\n"
	"            parse_str(html_entity_decode($info[\'query\']), $query);\n"
	"            if (!empty($params)) {\n"
	"                $params      = array_replace($query, $params);\n"
	"                $queryString = http_build_query($params, \'\', \'&\');\n"
	"            } else {\n"
	"                $params      = $query;\n"
	"                $queryString = $info[\'query\'];\n"
	"            }\n"
	"        } elseif (!empty($params)) {\n"
	"            $queryString = http_build_query($params, \'\', \'&\');\n"
	"        }\n"
	"        if ($queryString) {\n"
	"            parse_str($queryString, $get);\n"
	"            $options[\'get\'] = isset($options[\'get\']) ? array_merge($get, $options[\'get\']) : $get;\n"
	"        }\n"
	"\n"
	"        $server[\'REQUEST_URI\']  = $info[\'path\'] . (\'\' !== $queryString ? \'?\' . $queryString : \'\');\n"
	"        $server[\'QUERY_STRING\'] = $queryString;\n"
	"        $options[\'cookie\']      = $cookie;\n"
	"        $options[\'param\']       = $params;\n"
	"        $options[\'file\']        = $files;\n"
	"        $options[\'server\']      = $server;\n"
	"        $options[\'url\']         = $server[\'REQUEST_URI\'];\n"
	"        $options[\'baseUrl\']     = $info[\'path\'];\n"
	"        $options[\'pathinfo\']    = \'/\' == $info[\'path\'] ? \'/\' : ltrim($info[\'path\'], \'/\');\n"
	"        $options[\'method\']      = $server[\'REQUEST_METHOD\'];\n"
	"        $options[\'domain\']      = isset($info[\'scheme\']) ? $info[\'scheme\'] . \'://\' . $server[\'HTTP_HOST\'] : \'\';\n"
	"        $options[\'content\']     = $content;\n"
	"        self::$instance         = new self($options);\n"
	"        return self::$instance;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置或获取当前包含协议的域名\n"
	"     * @access public\n"
	"     * @param string $domain 域名\n"
	"     * @return string\n"
	"     */\n"
	"    public function domain($domain = null)\n"
	"    {\n"
	"        if (!is_null($domain)) {\n"
	"            $this->domain = $domain;\n"
	"            return $this;\n"
	"        } elseif (!$this->domain) {\n"
	"            $this->domain = $this->scheme() . \'://\' . $this->host();\n"
	"        }\n"
	"        return $this->domain;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置或获取当前完整URL 包括QUERY_STRING\n"
	"     * @access public\n"
	"     * @param string|true $url URL地址 true 带域名获取\n"
	"     * @return string\n"
	"     */\n"
	"    public function url($url = null)\n"
	"    {\n"
	"        if (!is_null($url) && true !== $url) {\n"
	"            $this->url = $url;\n"
	"            return $this;\n"
	"        } elseif (!$this->url) {\n"
	"            if (IS_CLI) {\n"
	"                $this->url = isset($_SERVER[\'argv\'][1]) ? $_SERVER[\'argv\'][1] : \'\';\n"
	"            } elseif (isset($_SERVER[\'HTTP_X_REWRITE_URL\'])) {\n"
	"                $this->url = $_SERVER[\'HTTP_X_REWRITE_URL\'];\n"
	"            } elseif (isset($_SERVER[\'REQUEST_URI\'])) {\n"
	"                $this->url = $_SERVER[\'REQUEST_URI\'];\n"
	"            } elseif (isset($_SERVER[\'ORIG_PATH_INFO\'])) {\n"
	"                $this->url = $_SERVER[\'ORIG_PATH_INFO\'] . (!empty($_SERVER[\'QUERY_STRING\']) ? \'?\' . $_SERVER[\'QUERY_STRING\'] : \'\');\n"
	"            } else {\n"
	"                $this->url = \'\';\n"
	"            }\n"
	"        }\n"
	"        return true === $url ? $this->domain() . $this->url : $this->url;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置或获取当前URL 不含QUERY_STRING\n"
	"     * @access public\n"
	"     * @param string $url URL地址\n"
	"     * @return string\n"
	"     */\n"
	"    public function baseUrl($url = null)\n"
	"    {\n"
	"        if (!is_null($url) && true !== $url) {\n"
	"            $this->baseUrl = $url;\n"
	"            return $this;\n"
	"        } elseif (!$this->baseUrl) {\n"
	"            $str           = $this->url();\n"
	"            $this->baseUrl = strpos($str, \'?\') ? strstr($str, \'?\', true) : $str;\n"
	"        }\n"
	"        return true === $url ? $this->domain() . $this->baseUrl : $this->baseUrl;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置或获取当前执行的文件 SCRIPT_NAME\n"
	"     * @access public\n"
	"     * @param string $file 当前执行的文件\n"
	"     * @return string\n"
	"     */\n"
	"    public function baseFile($file = null)\n"
	"    {\n"
	"        if (!is_null($file) && true !== $file) {\n"
	"            $this->baseFile = $file;\n"
	"            return $this;\n"
	"        } elseif (!$this->baseFile) {\n"
	"            $url = \'\';\n"
	"            if (!IS_CLI) {\n"
	"                $script_name = basename($_SERVER[\'SCRIPT_FILENAME\']);\n"
	"                if (basename($_SERVER[\'SCRIPT_NAME\']) === $script_name) {\n"
	"                    $url = $_SERVER[\'SCRIPT_NAME\'];\n"
	"                } elseif (basename($_SERVER[\'PHP_SELF\']) === $script_name) {\n"
	"                    $url = $_SERVER[\'PHP_SELF\'];\n"
	"                } elseif (isset($_SERVER[\'ORIG_SCRIPT_NAME\']) && basename($_SERVER[\'ORIG_SCRIPT_NAME\']) === $script_name) {\n"
	"                    $url = $_SERVER[\'ORIG_SCRIPT_NAME\'];\n"
	"                } elseif (($pos = strpos($_SERVER[\'PHP_SELF\'], \'/\' . $script_name)) !== false) {\n"
	"                    $url = substr($_SERVER[\'SCRIPT_NAME\'], 0, $pos) . \'/\' . $script_name;\n"
	"                } elseif (isset($_SERVER[\'DOCUMENT_ROOT\']) && strpos($_SERVER[\'SCRIPT_FILENAME\'], $_SERVER[\'DOCUMENT_ROOT\']) === 0) {\n"
	"                    $url = str_replace(\'\\\\\', \'/\', str_replace($_SERVER[\'DOCUMENT_ROOT\'], \'\', $_SERVER[\'SCRIPT_FILENAME\']));\n"
	"                }\n"
	"            }\n"
	"            $this->baseFile = $url;\n"
	"        }\n"
	"        return true === $file ? $this->domain() . $this->baseFile : $this->baseFile;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置或获取URL访问根地址\n"
	"     * @access public\n"
	"     * @param string $url URL地址\n"
	"     * @return string\n"
	"     */\n"
	"    public function root($url = null)\n"
	"    {\n"
	"        if (!is_null($url) && true !== $url) {\n"
	"            $this->root = $url;\n"
	"            return $this;\n"
	"        } elseif (!$this->root) {\n"
	"            $file = $this->baseFile();\n"
	"            if ($file && 0 !== strpos($this->url(), $file)) {\n"
	"                $file = str_replace(\'\\\\\', \'/\', dirname($file));\n"
	"            }\n"
	"            $this->root = rtrim($file, \'/\');\n"
	"        }\n"
	"        return true === $url ? $this->domain() . $this->root : $this->root;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取当前请求URL的pathinfo信息（含URL后缀）\n"
	"     * @access public\n"
	"     * @return string\n"
	"     */\n"
	"    public function pathinfo()\n"
	"    {\n"
	"        if (is_null($this->pathinfo)) {\n"
	"            if (isset($_GET[Config::get(\'var_pathinfo\')])) {\n"
	"                // 判断URL里面是否有兼容模式参数\n"
	"                $_SERVER[\'PATH_INFO\'] = $_GET[Config::get(\'var_pathinfo\')];\n"
	"                unset($_GET[Config::get(\'var_pathinfo\')]);\n"
	"            } elseif (IS_CLI) {\n"
	"                // CLI模式下 index.php module/controller/action/params/...\n"
	"                $_SERVER[\'PATH_INFO\'] = isset($_SERVER[\'argv\'][1]) ? $_SERVER[\'argv\'][1] : \'\';\n"
	"            }\n"
	"\n"
	"            // 分析PATHINFO信息\n"
	"            if (!isset($_SERVER[\'PATH_INFO\'])) {\n"
	"                foreach (Config::get(\'pathinfo_fetch\') as $type) {\n"
	"                    if (!empty($_SERVER[$type])) {\n"
	"                        $_SERVER[\'PATH_INFO\'] = (0 === strpos($_SERVER[$type], $_SERVER[\'SCRIPT_NAME\'])) ?\n"
	"                        substr($_SERVER[$type], strlen($_SERVER[\'SCRIPT_NAME\'])) : $_SERVER[$type];\n"
	"                        break;\n"
	"                    }\n"
	"                }\n"
	"            }\n"
	"            $this->pathinfo = empty($_SERVER[\'PATH_INFO\']) ? \'/\' : ltrim($_SERVER[\'PATH_INFO\'], \'/\');\n"
	"        }\n"
	"        return $this->pathinfo;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取当前请求URL的pathinfo信息(不含URL后缀)\n"
	"     * @access public\n"
	"     * @return string\n"
	"     */\n"
	"    public function path()\n"
	"    {\n"
	"        if (is_null($this->path)) {\n"
	"            $suffix   = Config::get(\'url_html_suffix\');\n"
	"            $pathinfo = $this->pathinfo();\n"
	"            if (false === $suffix) {\n"
	"                // 禁止伪静态访问\n"
	"                $this->path = $pathinfo;\n"
	"            } elseif ($suffix) {\n"
	"                // 去除正常的URL后缀\n"
	"                $this->path = preg_replace(\'/\\.(\' . ltrim($suffix, \'.\') . \')$/i\', \'\', $pathinfo);\n"
	"            } else {\n"
	"                // 允许任何后缀访问\n"
	"                $this->path = preg_replace(\'/\\.\' . $this->ext() . \'$/i\', \'\', $pathinfo);\n"
	"            }\n"
	"        }\n"
	"        return $this->path;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 当前URL的访问后缀\n"
	"     * @access public\n"
	"     * @return string\n"
	"     */\n"
	"    public function ext()\n"
	"    {\n"
	"        return pathinfo($this->pathinfo(), PATHINFO_EXTENSION);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取当前请求的时间\n"
	"     * @access public\n"
	"     * @param bool $float 是否使用浮点类型\n"
	"     * @return integer|float\n"
	"     */\n"
	"    public function time($float = false)\n"
	"    {\n"
	"        return $float ? $_SERVER[\'REQUEST_TIME_FLOAT\'] : $_SERVER[\'REQUEST_TIME\'];\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 当前请求的资源类型\n"
	"     * @access public\n"
	"     * @return false|string\n"
	"     */\n"
	"    public function type()\n"
	"    {\n"
	"        $accept = $this->server(\'HTTP_ACCEPT\');\n"
	"        if (empty($accept)) {\n"
	"            return false;\n"
	"        }\n"
	"\n"
	"        foreach ($this->mimeType as $key => $val) {\n"
	"            $array = explode(\',\', $val);\n"
	"            foreach ($array as $k => $v) {\n"
	"                if (stristr($accept, $v)) {\n"
	"                    return $key;\n"
	"                }\n"
	"            }\n"
	"        }\n"
	"        return false;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置资源类型\n"
	"     * @access public\n"
	"     * @param string|array $type 资源类型名\n"
	"     * @param string       $val  资源类型\n"
	"     * @return void\n"
	"     */\n"
	"    public function mimeType($type, $val = \'\')\n"
	"    {\n"
	"        if (is_array($type)) {\n"
	"            $this->mimeType = array_merge($this->mimeType, $type);\n"
	"        } else {\n"
	"            $this->mimeType[$type] = $val;\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 当前的请求类型\n"
	"     * @access public\n"
	"     * @param bool $method true 获取原始请求类型\n"
	"     * @return string\n"
	"     */\n"
	"    public function method($method = false)\n"
	"    {\n"
	"        if (true === $method) {\n"
	"            // 获取原始请求类型\n"
	"            return $this->server(\'REQUEST_METHOD\') ?: \'GET\';\n"
	"        } elseif (!$this->method) {\n"
	"            if (isset($_POST[Config::get(\'var_method\')])) {\n"
	"                $method = strtoupper($_POST[Config::get(\'var_method\')]);\n"
	"                if (in_array($method, [\'GET\', \'POST\', \'DELETE\', \'PUT\', \'PATCH\'])) {\n"
	"                    $this->method = $method;\n"
	"                    $this->{$this->method}($_POST);\n"
	"                } else {\n"
	"                    $this->method = \'POST\';\n"
	"                }\n"
	"                unset($_POST[Config::get(\'var_method\')]);\n"
	"            } elseif (isset($_SERVER[\'HTTP_X_HTTP_METHOD_OVERRIDE\'])) {\n"
	"                $this->method = strtoupper($_SERVER[\'HTTP_X_HTTP_METHOD_OVERRIDE\']);\n"
	"            } else {\n"
	"                $this->method = $this->server(\'REQUEST_METHOD\') ?: \'GET\';\n"
	"            }\n"
	"        }\n"
	"        return $this->method;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 是否为GET请求\n"
	"     * @access public\n"
	"     * @return bool\n"
	"     */\n"
	"    public function isGet()\n"
	"    {\n"
	"        return $this->method() == \'GET\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 是否为POST请求\n"
	"     * @access public\n"
	"     * @return bool\n"
	"     */\n"
	"    public function isPost()\n"
	"    {\n"
	"        return $this->method() == \'POST\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 是否为PUT请求\n"
	"     * @access public\n"
	"     * @return bool\n"
	"     */\n"
	"    public function isPut()\n"
	"    {\n"
	"        return $this->method() == \'PUT\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 是否为DELTE请求\n"
	"     * @access public\n"
	"     * @return bool\n"
	"     */\n"
	"    public function isDelete()\n"
	"    {\n"
	"        return $this->method() == \'DELETE\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 是否为HEAD请求\n"
	"     * @access public\n"
	"     * @return bool\n"
	"     */\n"
	"    public function isHead()\n"
	"    {\n"
	"        return $this->method() == \'HEAD\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 是否为PATCH请求\n"
	"     * @access public\n"
	"     * @return bool\n"
	"     */\n"
	"    public function isPatch()\n"
	"    {\n"
	"        return $this->method() == \'PATCH\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 是否为OPTIONS请求\n"
	"     * @access public\n"
	"     * @return bool\n"
	"     */\n"
	"    public function isOptions()\n"
	"    {\n"
	"        return $this->method() == \'OPTIONS\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 是否为cli\n"
	"     * @access public\n"
	"     * @return bool\n"
	"     */\n"
	"    public function isCli()\n"
	"    {\n"
	"        return PHP_SAPI == \'cli\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 是否为cgi\n"
	"     * @access public\n"
	"     * @return bool\n"
	"     */\n"
	"    public function isCgi()\n"
	"    {\n"
	"        return strpos(PHP_SAPI, \'cgi\') === 0;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取当前请求的参数\n"
	"     * @access public\n"
	"     * @param string|array $name    变量名\n"
	"     * @param mixed        $default 默认值\n"
	"     * @param string|array $filter  过滤方法\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function param($name = \'\', $default = null, $filter = \'\')\n"
	"    {\n"
	"        if (empty($this->mergeParam)) {\n"
	"            $method = $this->method(true);\n"
	"            // 自动获取请求变量\n"
	"            switch ($method) {\n"
	"                case \'POST\':\n"
	"                    $vars = $this->post(false);\n"
	"                    break;\n"
	"                case \'PUT\':\n"
	"                case \'DELETE\':\n"
	"                case \'PATCH\':\n"
	"                    $vars = $this->put(false);\n"
	"                    break;\n"
	"                default:\n"
	"                    $vars = [];\n"
	"            }\n"
	"            // 当前请求参数和URL地址中的参数合并\n"
	"            $this->param      = array_merge($this->param, $this->get(false), $vars, $this->route(false));\n"
	"            $this->mergeParam = true;\n"
	"        }\n"
	"        if (true === $name) {\n"
	"            // 获取包含文件上传信息的数组\n"
	"            $file = $this->file();\n"
	"            $data = is_array($file) ? array_merge($this->param, $file) : $this->param;\n"
	"            return $this->input($data, \'\', $default, $filter);\n"
	"        }\n"
	"        return $this->input($this->param, $name, $default, $filter);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置获取路由参数\n"
	"     * @access public\n"
	"     * @param string|array $name    变量名\n"
	"     * @param mixed        $default 默认值\n"
	"     * @param string|array $filter  过滤方法\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function route($name = \'\', $default = null, $filter = \'\')\n"
	"    {\n"
	"        if (is_array($name)) {\n"
	"            $this->param        = [];\n"
	"            $this->mergeParam   = false;\n"
	"            return $this->route = array_merge($this->route, $name);\n"
	"        }\n"
	"        return $this->input($this->route, $name, $default, $filter);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置获取GET参数\n"
	"     * @access public\n"
	"     * @param string|array $name    变量名\n"
	"     * @param mixed        $default 默认值\n"
	"     * @param string|array $filter  过滤方法\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function get($name = \'\', $default = null, $filter = \'\')\n"
	"    {\n"
	"        if (empty($this->get)) {\n"
	"            $this->get = $_GET;\n"
	"        }\n"
	"        if (is_array($name)) {\n"
	"            $this->param      = [];\n"
	"            $this->mergeParam = false;\n"
	"            return $this->get = array_merge($this->get, $name);\n"
	"        }\n"
	"        return $this->input($this->get, $name, $default, $filter);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置获取POST参数\n"
	"     * @access public\n"
	"     * @param string       $name    变量名\n"
	"     * @param mixed        $default 默认值\n"
	"     * @param string|array $filter  过滤方法\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function post($name = \'\', $default = null, $filter = \'\')\n"
	"    {\n"
	"        if (empty($this->post)) {\n"
	"            $content = $this->input;\n"
	"            if (empty($_POST) && false !== strpos($this->contentType(), \'application/json\')) {\n"
	"                $this->post = (array) json_decode($content, true);\n"
	"            } else {\n"
	"                $this->post = $_POST;\n"
	"            }\n"
	"        }\n"
	"        if (is_array($name)) {\n"
	"            $this->param       = [];\n"
	"            $this->mergeParam  = false;\n"
	"            return $this->post = array_merge($this->post, $name);\n"
	"        }\n"
	"        return $this->input($this->post, $name, $default, $filter);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置获取PUT参数\n"
	"     * @access public\n"
	"     * @param string|array $name    变量名\n"
	"     * @param mixed        $default 默认值\n"
	"     * @param string|array $filter  过滤方法\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function put($name = \'\', $default = null, $filter = \'\')\n"
	"    {\n"
	"        if (is_null($this->put)) {\n"
	"            $content = $this->input;\n"
	"            if (false !== strpos($this->contentType(), \'application/json\')) {\n"
	"                $this->put = (array) json_decode($content, true);\n"
	"            } else {\n"
	"                parse_str($content, $this->put);\n"
	"            }\n"
	"        }\n"
	"        if (is_array($name)) {\n"
	"            $this->param      = [];\n"
	"            $this->mergeParam = false;\n"
	"            return $this->put = is_null($this->put) ? $name : array_merge($this->put, $name);\n"
	"        }\n"
	"\n"
	"        return $this->input($this->put, $name, $default, $filter);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置获取DELETE参数\n"
	"     * @access public\n"
	"     * @param string|array $name    变量名\n"
	"     * @param mixed        $default 默认值\n"
	"     * @param string|array $filter  过滤方法\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function delete($name = \'\', $default = null, $filter = \'\')\n"
	"    {\n"
	"        return $this->put($name, $default, $filter);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置获取PATCH参数\n"
	"     * @access public\n"
	"     * @param string|array $name    变量名\n"
	"     * @param mixed        $default 默认值\n"
	"     * @param string|array $filter  过滤方法\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function patch($name = \'\', $default = null, $filter = \'\')\n"
	"    {\n"
	"        return $this->put($name, $default, $filter);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取request变量\n"
	"     * @param string       $name    数据名称\n"
	"     * @param string       $default 默认值\n"
	"     * @param string|array $filter  过滤方法\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function request($name = \'\', $default = null, $filter = \'\')\n"
	"    {\n"
	"        if (empty($this->request)) {\n"
	"            $this->request = $_REQUEST;\n"
	"        }\n"
	"        if (is_array($name)) {\n"
	"            $this->param          = [];\n"
	"            $this->mergeParam     = false;\n"
	"            return $this->request = array_merge($this->request, $name);\n"
	"        }\n"
	"        return $this->input($this->request, $name, $default, $filter);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取session数据\n"
	"     * @access public\n"
	"     * @param string|array $name    数据名称\n"
	"     * @param string       $default 默认值\n"
	"     * @param string|array $filter  过滤方法\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function session($name = \'\', $default = null, $filter = \'\')\n"
	"    {\n"
	"        if (empty($this->session)) {\n"
	"            $this->session = Session::get();\n"
	"        }\n"
	"        if (is_array($name)) {\n"
	"            return $this->session = array_merge($this->session, $name);\n"
	"        }\n"
	"        return $this->input($this->session, $name, $default, $filter);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取cookie参数\n"
	"     * @access public\n"
	"     * @param string|array $name    数据名称\n"
	"     * @param string       $default 默认值\n"
	"     * @param string|array $filter  过滤方法\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function cookie($name = \'\', $default = null, $filter = \'\')\n"
	"    {\n"
	"        if (empty($this->cookie)) {\n"
	"            $this->cookie = Cookie::get();\n"
	"        }\n"
	"        if (is_array($name)) {\n"
	"            return $this->cookie = array_merge($this->cookie, $name);\n"
	"        } elseif (!empty($name)) {\n"
	"            $data = Cookie::has($name) ? Cookie::get($name) : $default;\n"
	"        } else {\n"
	"            $data = $this->cookie;\n"
	"        }\n"
	"\n"
	"        // 解析过滤器\n"
	"        $filter = $this->getFilter($filter, $default);\n"
	"\n"
	"        if (is_array($data)) {\n"
	"            array_walk_recursive($data, [$this, \'filterValue\'], $filter);\n"
	"            reset($data);\n"
	"        } else {\n"
	"            $this->filterValue($data, $name, $filter);\n"
	"        }\n"
	"        return $data;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取server参数\n"
	"     * @access public\n"
	"     * @param string|array $name    数据名称\n"
	"     * @param string       $default 默认值\n"
	"     * @param string|array $filter  过滤方法\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function server($name = \'\', $default = null, $filter = \'\')\n"
	"    {\n"
	"        if (empty($this->server)) {\n"
	"            $this->server = $_SERVER;\n"
	"        }\n"
	"        if (is_array($name)) {\n"
	"            return $this->server = array_merge($this->server, $name);\n"
	"        }\n"
	"        return $this->input($this->server, false === $name ? false : strtoupper($name), $default, $filter);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取上传的文件信息\n"
	"     * @access public\n"
	"     * @param string|array $name 名称\n"
	"     * @return null|array|\\think\\File\n"
	"     */\n"
	"    public function file($name = \'\')\n"
	"    {\n"
	"        if (empty($this->file)) {\n"
	"            $this->file = isset($_FILES) ? $_FILES : [];\n"
	"        }\n"
	"        if (is_array($name)) {\n"
	"            return $this->file = array_merge($this->file, $name);\n"
	"        }\n"
	"        $files = $this->file;\n"
	"        if (!empty($files)) {\n"
	"            // 处理上传文件\n"
	"            $array = [];\n"
	"            foreach ($files as $key => $file) {\n"
	"                if (is_array($file[\'name\'])) {\n"
	"                    $item  = [];\n"
	"                    $keys  = array_keys($file);\n"
	"                    $count = count($file[\'name\']);\n"
	"                    for ($i = 0; $i < $count; $i++) {\n"
	"                        if (empty($file[\'tmp_name\'][$i]) || !is_file($file[\'tmp_name\'][$i])) {\n"
	"                            continue;\n"
	"                        }\n"
	"                        $temp[\'key\'] = $key;\n"
	"                        foreach ($keys as $_key) {\n"
	"                            $temp[$_key] = $file[$_key][$i];\n"
	"                        }\n"
	"                        $item[] = (new File($temp[\'tmp_name\']))->setUploadInfo($temp);\n"
	"                    }\n"
	"                    $array[$key] = $item;\n"
	"                } else {\n"
	"                    if ($file instanceof File) {\n"
	"                        $array[$key] = $file;\n"
	"                    } else {\n"
	"                        if (empty($file[\'tmp_name\']) || !is_file($file[\'tmp_name\'])) {\n"
	"                            continue;\n"
	"                        }\n"
	"                        $array[$key] = (new File($file[\'tmp_name\']))->setUploadInfo($file);\n"
	"                    }\n"
	"                }\n"
	"            }\n"
	"            if (strpos($name, \'.\')) {\n"
	"                list($name, $sub) = explode(\'.\', $name);\n"
	"            }\n"
	"            if (\'\' === $name) {\n"
	"                // 获取全部文件\n"
	"                return $array;\n"
	"            } elseif (isset($sub) && isset($array[$name][$sub])) {\n"
	"                return $array[$name][$sub];\n"
	"            } elseif (isset($array[$name])) {\n"
	"                return $array[$name];\n"
	"            }\n"
	"        }\n"
	"        return;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取环境变量\n"
	"     * @param string|array $name    数据名称\n"
	"     * @param string       $default 默认值\n"
	"     * @param string|array $filter  过滤方法\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function env($name = \'\', $default = null, $filter = \'\')\n"
	"    {\n"
	"        if (empty($this->env)) {\n"
	"            $this->env = $_ENV;\n"
	"        }\n"
	"        if (is_array($name)) {\n"
	"            return $this->env = array_merge($this->env, $name);\n"
	"        }\n"
	"        return $this->input($this->env, false === $name ? false : strtoupper($name), $default, $filter);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置或者获取当前的Header\n"
	"     * @access public\n"
	"     * @param string|array $name    header名称\n"
	"     * @param string       $default 默认值\n"
	"     * @return string\n"
	"     */\n"
	"    public function header($name = \'\', $default = null)\n"
	"    {\n"
	"        if (empty($this->header)) {\n"
	"            $header = [];\n"
	"            if (function_exists(\'apache_request_headers\') && $result = apache_request_headers()) {\n"
	"                $header = $result;\n"
	"            } else {\n"
	"                $server = $this->server ?: $_SERVER;\n"
	"                foreach ($server as $key => $val) {\n"
	"                    if (0 === strpos($key, \'HTTP_\')) {\n"
	"                        $key          = str_replace(\'_\', \'-\', strtolower(substr($key, 5)));\n"
	"                        $header[$key] = $val;\n"
	"                    }\n"
	"                }\n"
	"                if (isset($server[\'CONTENT_TYPE\'])) {\n"
	"                    $header[\'content-type\'] = $server[\'CONTENT_TYPE\'];\n"
	"                }\n"
	"                if (isset($server[\'CONTENT_LENGTH\'])) {\n"
	"                    $header[\'content-length\'] = $server[\'CONTENT_LENGTH\'];\n"
	"                }\n"
	"            }\n"
	"            $this->header = array_change_key_case($header);\n"
	"        }\n"
	"        if (is_array($name)) {\n"
	"            return $this->header = array_merge($this->header, $name);\n"
	"        }\n"
	"        if (\'\' === $name) {\n"
	"            return $this->header;\n"
	"        }\n"
	"        $name = str_replace(\'_\', \'-\', strtolower($name));\n"
	"        return isset($this->header[$name]) ? $this->header[$name] : $default;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取变量 支持过滤和默认值\n"
	"     * @param array        $data    数据源\n"
	"     * @param string|false $name    字段名\n"
	"     * @param mixed        $default 默认值\n"
	"     * @param string|array $filter  过滤函数\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function input($data = [], $name = \'\', $default = null, $filter = \'\')\n"
	"    {\n"
	"        if (false === $name) {\n"
	"            // 获取原始数据\n"
	"            return $data;\n"
	"        }\n"
	"        $name = (string) $name;\n"
	"        if (\'\' != $name) {\n"
	"            // 解析name\n"
	"            if (strpos($name, \'/\')) {\n"
	"                list($name, $type) = explode(\'/\', $name);\n"
	"            } else {\n"
	"                $type = \'s\';\n"
	"            }\n"
	"            // 按.拆分成多维数组进行判断\n"
	"            foreach (explode(\'.\', $name) as $val) {\n"
	"                if (isset($data[$val])) {\n"
	"                    $data = $data[$val];\n"
	"                } else {\n"
	"                    // 无输入数据，返回默认值\n"
	"                    return $default;\n"
	"                }\n"
	"            }\n"
	"            if (is_object($data)) {\n"
	"                return $data;\n"
	"            }\n"
	"        }\n"
	"\n"
	"        // 解析过滤器\n"
	"        $filter = $this->getFilter($filter, $default);\n"
	"\n"
	"        if (is_array($data)) {\n"
	"            array_walk_recursive($data, [$this, \'filterValue\'], $filter);\n"
	"            reset($data);\n"
	"        } else {\n"
	"            $this->filterValue($data, $name, $filter);\n"
	"        }\n"
	"\n"
	"        if (isset($type) && $data !== $default) {\n"
	"            // 强制类型转换\n"
	"            $this->typeCast($data, $type);\n"
	"        }\n"
	"        return $data;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置或获取当前的过滤规则\n"
	"     * @param mixed $filter 过滤规则\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function filter($filter = null)\n"
	"    {\n"
	"        if (is_null($filter)) {\n"
	"            return $this->filter;\n"
	"        } else {\n"
	"            $this->filter = $filter;\n"
	"        }\n"
	"    }\n"
	"\n"
	"    protected function getFilter($filter, $default)\n"
	"    {\n"
	"        if (is_null($filter)) {\n"
	"            $filter = [];\n"
	"        } else {\n"
	"            $filter = $filter ?: $this->filter;\n"
	"            if (is_string($filter) && false === strpos($filter, \'/\')) {\n"
	"                $filter = explode(\',\', $filter);\n"
	"            } else {\n"
	"                $filter = (array) $filter;\n"
	"            }\n"
	"        }\n"
	"\n"
	"        $filter[] = $default;\n"
	"        return $filter;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 递归过滤给定的值\n"
	"     * @param mixed $value   键值\n"
	"     * @param mixed $key     键名\n"
	"     * @param array $filters 过滤方法+默认值\n"
	"     * @return mixed\n"
	"     */\n"
	"    private function filterValue(&$value, $key, $filters)\n"
	"    {\n"
	"        $default = array_pop($filters);\n"
	"        foreach ($filters as $filter) {\n"
	"            if (is_callable($filter)) {\n"
	"                // 调用函数或者方法过滤\n"
	"                $value = call_user_func($filter, $value);\n"
	"            } elseif (is_scalar($value)) {\n"
	"                if (false !== strpos($filter, \'/\')) {\n"
	"                    // 正则过滤\n"
	"                    if (!preg_match($filter, $value)) {\n"
	"                        // 匹配不成功返回默认值\n"
	"                        $value = $default;\n"
	"                        break;\n"
	"                    }\n"
	"                } elseif (!empty($filter)) {\n"
	"                    // filter函数不存在时, 则使用filter_var进行过滤\n"
	"                    // filter为非整形值时, 调用filter_id取得过滤id\n"
	"                    $value = filter_var($value, is_int($filter) ? $filter : filter_id($filter));\n"
	"                    if (false === $value) {\n"
	"                        $value = $default;\n"
	"                        break;\n"
	"                    }\n"
	"                }\n"
	"            }\n"
	"        }\n"
	"        return $this->filterExp($value);\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 过滤表单中的表达式\n"
	"     * @param string $value\n"
	"     * @return void\n"
	"     */\n"
	"    public function filterExp(&$value)\n"
	"    {\n"
	"        // 过滤查询特殊字符\n"
	"        if (is_string($value) && preg_match(\'/^(EXP|NEQ|GT|EGT|LT|ELT|OR|XOR|LIKE|NOTLIKE|NOT LIKE|NOT BETWEEN|NOTBETWEEN|BETWEEN|NOT EXISTS|NOTEXISTS|EXISTS|NOT NULL|NOTNULL|NULL|BETWEEN TIME|NOT BETWEEN TIME|NOTBETWEEN TIME|NOTIN|NOT IN|IN)$/i\', $value)) {\n"
	"            $value .= \' \';\n"
	"        }\n"
	"        // TODO 其他安全过滤\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 强制类型转换\n"
	"     * @param string $data\n"
	"     * @param string $type\n"
	"     * @return mixed\n"
	"     */\n"
	"    private function typeCast(&$data, $type)\n"
	"    {\n"
	"        switch (strtolower($type)) {\n"
	"            // 数组\n"
	"            case \'a\':\n"
	"                $data = (array) $data;\n"
	"                break;\n"
	"            // 数字\n"
	"            case \'d\':\n"
	"                $data = (int) $data;\n"
	"                break;\n"
	"            // 浮点\n"
	"            case \'f\':\n"
	"                $data = (float) $data;\n"
	"                break;\n"
	"            // 布尔\n"
	"            case \'b\':\n"
	"                $data = (boolean) $data;\n"
	"                break;\n"
	"            // 字符串\n"
	"            case \'s\':\n"
	"            default:\n"
	"                if (is_scalar($data)) {\n"
	"                    $data = (string) $data;\n"
	"                } else {\n"
	"                    throw new \\InvalidArgumentException(\'variable type error：\' . gettype($data));\n"
	"                }\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 是否存在某个请求参数\n"
	"     * @access public\n"
	"     * @param string $name       变量名\n"
	"     * @param string $type       变量类型\n"
	"     * @param bool   $checkEmpty 是否检测空值\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function has($name, $type = \'param\', $checkEmpty = false)\n"
	"    {\n"
	"        if (empty($this->$type)) {\n"
	"            $param = $this->$type();\n"
	"        } else {\n"
	"            $param = $this->$type;\n"
	"        }\n"
	"        // 按.拆分成多维数组进行判断\n"
	"        foreach (explode(\'.\', $name) as $val) {\n"
	"            if (isset($param[$val])) {\n"
	"                $param = $param[$val];\n"
	"            } else {\n"
	"                return false;\n"
	"            }\n"
	"        }\n"
	"        return ($checkEmpty && \'\' === $param) ? false : true;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取指定的参数\n"
	"     * @access public\n"
	"     * @param string|array $name 变量名\n"
	"     * @param string       $type 变量类型\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function only($name, $type = \'param\')\n"
	"    {\n"
	"        $param = $this->$type();\n"
	"        if (is_string($name)) {\n"
	"            $name = explode(\',\', $name);\n"
	"        }\n"
	"        $item = [];\n"
	"        foreach ($name as $key) {\n"
	"            if (isset($param[$key])) {\n"
	"                $item[$key] = $param[$key];\n"
	"            }\n"
	"        }\n"
	"        return $item;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 排除指定参数获取\n"
	"     * @access public\n"
	"     * @param string|array $name 变量名\n"
	"     * @param string       $type 变量类型\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function except($name, $type = \'param\')\n"
	"    {\n"
	"        $param = $this->$type();\n"
	"        if (is_string($name)) {\n"
	"            $name = explode(\',\', $name);\n"
	"        }\n"
	"        foreach ($name as $key) {\n"
	"            if (isset($param[$key])) {\n"
	"                unset($param[$key]);\n"
	"            }\n"
	"        }\n"
	"        return $param;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 当前是否ssl\n"
	"     * @access public\n"
	"     * @return bool\n"
	"     */\n"
	"    public function isSsl()\n"
	"    {\n"
	"        $server = array_merge($_SERVER, $this->server);\n"
	"        if (isset($server[\'HTTPS\']) && (\'1\' == $server[\'HTTPS\'] || \'on\' == strtolower($server[\'HTTPS\']))) {\n"
	"            return true;\n"
	"        } elseif (isset($server[\'REQUEST_SCHEME\']) && \'https\' == $server[\'REQUEST_SCHEME\']) {\n"
	"            return true;\n"
	"        } elseif (isset($server[\'SERVER_PORT\']) && (\'443\' == $server[\'SERVER_PORT\'])) {\n"
	"            return true;\n"
	"        } elseif (isset($server[\'HTTP_X_FORWARDED_PROTO\']) && \'https\' == $server[\'HTTP_X_FORWARDED_PROTO\']) {\n"
	"            return true;\n"
	"        } elseif (Config::get(\'https_agent_name\') && isset($server[Config::get(\'https_agent_name\')])) {\n"
	"            return true;\n"
	"        }\n"
	"        return false;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 当前是否Ajax请求\n"
	"     * @access public\n"
	"     * @param bool $ajax true 获取原始ajax请求\n"
	"     * @return bool\n"
	"     */\n"
	"    public function isAjax($ajax = false)\n"
	"    {\n"
	"        $value  = $this->server(\'HTTP_X_REQUESTED_WITH\', \'\', \'strtolower\');\n"
	"        $result = (\'xmlhttprequest\' == $value) ? true : false;\n"
	"        if (true === $ajax) {\n"
	"            return $result;\n"
	"        } else {\n"
	"            $result           = $this->param(Config::get(\'var_ajax\')) ? true : $result;\n"
	"            $this->mergeParam = false;\n"
	"            return $result;\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 当前是否Pjax请求\n"
	"     * @access public\n"
	"     * @param bool $pjax true 获取原始pjax请求\n"
	"     * @return bool\n"
	"     */\n"
	"    public function isPjax($pjax = false)\n"
	"    {\n"
	"        $result = !is_null($this->server(\'HTTP_X_PJAX\')) ? true : false;\n"
	"        if (true === $pjax) {\n"
	"            return $result;\n"
	"        } else {\n"
	"            $result           = $this->param(Config::get(\'var_pjax\')) ? true : $result;\n"
	"            $this->mergeParam = false;\n"
	"            return $result;\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取客户端IP地址\n"
	"     * @param integer $type 返回类型 0 返回IP地址 1 返回IPV4地址数字\n"
	"     * @param boolean $adv  是否进行高级模式获取（有可能被伪装）\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function ip($type = 0, $adv = true)\n"
	"    {\n"
	"        $type      = $type ? 1 : 0;\n"
	"        static $ip = null;\n"
	"        if (null !== $ip) {\n"
	"            return $ip[$type];\n"
	"        }\n"
	"\n"
	"        $httpAgentIp = Config::get(\'http_agent_ip\');\n"
	"\n"
	"        if ($httpAgentIp && isset($_SERVER[$httpAgentIp])) {\n"
	"            $ip = $_SERVER[$httpAgentIp];\n"
	"        } elseif ($adv) {\n"
	"            if (isset($_SERVER[\'HTTP_X_FORWARDED_FOR\'])) {\n"
	"                $arr = explode(\',\', $_SERVER[\'HTTP_X_FORWARDED_FOR\']);\n"
	"                $pos = array_search(\'unknown\', $arr);\n"
	"                if (false !== $pos) {\n"
	"                    unset($arr[$pos]);\n"
	"                }\n"
	"                $ip = trim(current($arr));\n"
	"            } elseif (isset($_SERVER[\'HTTP_CLIENT_IP\'])) {\n"
	"                $ip = $_SERVER[\'HTTP_CLIENT_IP\'];\n"
	"            } elseif (isset($_SERVER[\'REMOTE_ADDR\'])) {\n"
	"                $ip = $_SERVER[\'REMOTE_ADDR\'];\n"
	"            }\n"
	"        } elseif (isset($_SERVER[\'REMOTE_ADDR\'])) {\n"
	"            $ip = $_SERVER[\'REMOTE_ADDR\'];\n"
	"        }\n"
	"        // IP地址合法验证\n"
	"        $long = sprintf(\"%u\", ip2long($ip));\n"
	"        $ip   = $long ? [$ip, $long] : [\'0.0.0.0\', 0];\n"
	"        return $ip[$type];\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 检测是否使用手机访问\n"
	"     * @access public\n"
	"     * @return bool\n"
	"     */\n"
	"    public function isMobile()\n"
	"    {\n"
	"        if (isset($_SERVER[\'HTTP_VIA\']) && stristr($_SERVER[\'HTTP_VIA\'], \"wap\")) {\n"
	"            return true;\n"
	"        } elseif (isset($_SERVER[\'HTTP_ACCEPT\']) && strpos(strtoupper($_SERVER[\'HTTP_ACCEPT\']), \"VND.WAP.WML\")) {\n"
	"            return true;\n"
	"        } elseif (isset($_SERVER[\'HTTP_X_WAP_PROFILE\']) || isset($_SERVER[\'HTTP_PROFILE\'])) {\n"
	"            return true;\n"
	"        } elseif (isset($_SERVER[\'HTTP_USER_AGENT\']) && preg_match(\'/(blackberry|configuration\\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i\', $_SERVER[\'HTTP_USER_AGENT\'])) {\n"
	"            return true;\n"
	"        } else {\n"
	"            return false;\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 当前URL地址中的scheme参数\n"
	"     * @access public\n"
	"     * @return string\n"
	"     */\n"
	"    public function scheme()\n"
	"    {\n"
	"        return $this->isSsl() ? \'https\' : \'http\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 当前请求URL地址中的query参数\n"
	"     * @access public\n"
	"     * @return string\n"
	"     */\n"
	"    public function query()\n"
	"    {\n"
	"        return $this->server(\'QUERY_STRING\');\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 当前请求的host\n"
	"     * @access public\n"
	"     * @param bool $strict true 仅仅获取HOST\n"
	"     * @return string\n"
	"     */\n"
	"    public function host($strict = false)\n"
	"    {\n"
	"        if (isset($_SERVER[\'HTTP_X_REAL_HOST\'])) {\n"
	"            $host = $_SERVER[\'HTTP_X_REAL_HOST\'];\n"
	"        } else {\n"
	"            $host = $this->server(\'HTTP_HOST\');\n"
	"        }\n"
	"\n"
	"        return true === $strict && strpos($host, \':\') ? strstr($host, \':\', true) : $host;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 当前请求URL地址中的port参数\n"
	"     * @access public\n"
	"     * @return integer\n"
	"     */\n"
	"    public function port()\n"
	"    {\n"
	"        return $this->server(\'SERVER_PORT\');\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 当前请求 SERVER_PROTOCOL\n"
	"     * @access public\n"
	"     * @return integer\n"
	"     */\n"
	"    public function protocol()\n"
	"    {\n"
	"        return $this->server(\'SERVER_PROTOCOL\');\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 当前请求 REMOTE_PORT\n"
	"     * @access public\n"
	"     * @return integer\n"
	"     */\n"
	"    public function remotePort()\n"
	"    {\n"
	"        return $this->server(\'REMOTE_PORT\');\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 当前请求 HTTP_CONTENT_TYPE\n"
	"     * @access public\n"
	"     * @return string\n"
	"     */\n"
	"    public function contentType()\n"
	"    {\n"
	"        $contentType = $this->server(\'CONTENT_TYPE\');\n"
	"        if ($contentType) {\n"
	"            if (strpos($contentType, \';\')) {\n"
	"                list($type) = explode(\';\', $contentType);\n"
	"            } else {\n"
	"                $type = $contentType;\n"
	"            }\n"
	"            return trim($type);\n"
	"        }\n"
	"        return \'\';\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取当前请求的路由信息\n"
	"     * @access public\n"
	"     * @param array $route 路由名称\n"
	"     * @return array\n"
	"     */\n"
	"    public function routeInfo($route = [])\n"
	"    {\n"
	"        if (!empty($route)) {\n"
	"            $this->routeInfo = $route;\n"
	"        } else {\n"
	"            return $this->routeInfo;\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置或者获取当前请求的调度信息\n"
	"     * @access public\n"
	"     * @param array $dispatch 调度信息\n"
	"     * @return array\n"
	"     */\n"
	"    public function dispatch($dispatch = null)\n"
	"    {\n"
	"        if (!is_null($dispatch)) {\n"
	"            $this->dispatch = $dispatch;\n"
	"        }\n"
	"        return $this->dispatch;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置或者获取当前的模块名\n"
	"     * @access public\n"
	"     * @param string $module 模块名\n"
	"     * @return string|Request\n"
	"     */\n"
	"    public function module($module = null)\n"
	"    {\n"
	"        if (!is_null($module)) {\n"
	"            $this->module = $module;\n"
	"            return $this;\n"
	"        } else {\n"
	"            return $this->module ?: \'\';\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置或者获取当前的控制器名\n"
	"     * @access public\n"
	"     * @param string $controller 控制器名\n"
	"     * @return string|Request\n"
	"     */\n"
	"    public function controller($controller = null)\n"
	"    {\n"
	"        if (!is_null($controller)) {\n"
	"            $this->controller = $controller;\n"
	"            return $this;\n"
	"        } else {\n"
	"            return $this->controller ?: \'\';\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置或者获取当前的操作名\n"
	"     * @access public\n"
	"     * @param string $action 操作名\n"
	"     * @return string|Request\n"
	"     */\n"
	"    public function action($action = null)\n"
	"    {\n"
	"        if (!is_null($action) && !is_bool($action)) {\n"
	"            $this->action = $action;\n"
	"            return $this;\n"
	"        } else {\n"
	"            $name = $this->action ?: \'\';\n"
	"            return true === $action ? $name : strtolower($name);\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置或者获取当前的语言\n"
	"     * @access public\n"
	"     * @param string $lang 语言名\n"
	"     * @return string|Request\n"
	"     */\n"
	"    public function langset($lang = null)\n"
	"    {\n"
	"        if (!is_null($lang)) {\n"
	"            $this->langset = $lang;\n"
	"            return $this;\n"
	"        } else {\n"
	"            return $this->langset ?: \'\';\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置或者获取当前请求的content\n"
	"     * @access public\n"
	"     * @return string\n"
	"     */\n"
	"    public function getContent()\n"
	"    {\n"
	"        if (is_null($this->content)) {\n"
	"            $this->content = $this->input;\n"
	"        }\n"
	"        return $this->content;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 获取当前请求的php://input\n"
	"     * @access public\n"
	"     * @return string\n"
	"     */\n"
	"    public function getInput()\n"
	"    {\n"
	"        return $this->input;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 生成请求令牌\n"
	"     * @access public\n"
	"     * @param string $name 令牌名称\n"
	"     * @param mixed  $type 令牌生成方法\n"
	"     * @return string\n"
	"     */\n"
	"    public function token($name = \'__token__\', $type = \'md5\')\n"
	"    {\n"
	"        $type  = is_callable($type) ? $type : \'md5\';\n"
	"        $token = call_user_func($type, $_SERVER[\'REQUEST_TIME_FLOAT\']);\n"
	"        if ($this->isAjax()) {\n"
	"            header($name . \': \' . $token);\n"
	"        }\n"
	"        Session::set($name, $token);\n"
	"        return $token;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置当前地址的请求缓存\n"
	"     * @access public\n"
	"     * @param string $key    缓存标识，支持变量规则 ，例如 item/:name/:id\n"
	"     * @param mixed  $expire 缓存有效期\n"
	"     * @param array  $except 缓存排除\n"
	"     * @param string $tag    缓存标签\n"
	"     * @return void\n"
	"     */\n"
	"    public function cache($key, $expire = null, $except = [], $tag = null)\n"
	"    {\n"
	"        if (!is_array($except)) {\n"
	"            $tag    = $except;\n"
	"            $except = [];\n"
	"        }\n"
	"\n"
	"        if (false !== $key && $this->isGet() && !$this->isCheckCache) {\n"
	"            // 标记请求缓存检查\n"
	"            $this->isCheckCache = true;\n"
	"            if (false === $expire) {\n"
	"                // 关闭当前缓存\n"
	"                return;\n"
	"            }\n"
	"            if ($key instanceof \\Closure) {\n"
	"                $key = call_user_func_array($key, [$this]);\n"
	"            } elseif (true === $key) {\n"
	"                foreach ($except as $rule) {\n"
	"                    if (0 === stripos($this->url(), $rule)) {\n"
	"                        return;\n"
	"                    }\n"
	"                }\n"
	"                // 自动缓存功能\n"
	"                $key = \'__URL__\';\n"
	"            } elseif (strpos($key, \'|\')) {\n"
	"                list($key, $fun) = explode(\'|\', $key);\n"
	"            }\n"
	"            // 特殊规则替换\n"
	"            if (false !== strpos($key, \'__\')) {\n"
	"                $key = str_replace([\'__MODULE__\', \'__CONTROLLER__\', \'__ACTION__\', \'__URL__\', \'\'], [$this->module, $this->controller, $this->action, md5($this->url(true))], $key);\n"
	"            }\n"
	"\n"
	"            if (false !== strpos($key, \':\')) {\n"
	"                $param = $this->param();\n"
	"                foreach ($param as $item => $val) {\n"
	"                    if (is_string($val) && false !== strpos($key, \':\' . $item)) {\n"
	"                        $key = str_replace(\':\' . $item, $val, $key);\n"
	"                    }\n"
	"                }\n"
	"            } elseif (strpos($key, \']\')) {\n"
	"                if (\'[\' . $this->ext() . \']\' == $key) {\n"
	"                    // 缓存某个后缀的请求\n"
	"                    $key = md5($this->url());\n"
	"                } else {\n"
	"                    return;\n"
	"                }\n"
	"            }\n"
	"            if (isset($fun)) {\n"
	"                $key = $fun($key);\n"
	"            }\n"
	"\n"
	"            if (strtotime($this->server(\'HTTP_IF_MODIFIED_SINCE\')) + $expire > $_SERVER[\'REQUEST_TIME\']) {\n"
	"                // 读取缓存\n"
	"                $response = Response::create()->code(304);\n"
	"                throw new \\think\\exception\\HttpResponseException($response);\n"
	"            } elseif (Cache::has($key)) {\n"
	"                list($content, $header) = Cache::get($key);\n"
	"                $response               = Response::create($content)->header($header);\n"
	"                throw new \\think\\exception\\HttpResponseException($response);\n"
	"            } else {\n"
	"                $this->cache = [$key, $expire, $tag];\n"
	"            }\n"
	"        }\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 读取请求缓存设置\n"
	"     * @access public\n"
	"     * @return array\n"
	"     */\n"
	"    public function getCache()\n"
	"    {\n"
	"        return $this->cache;\n"
	"    }\n"
	"\n"
	"    /**\n"
	"     * 设置当前请求绑定的对象实例\n"
	"     * @access public\n"
	"     * @param string|array $name 绑定的对象标识\n"
	"     * @param mixed        $obj  绑定的对象实例\n"
	"     * @return mixed\n"
	"     */\n"
	"    public function bind($name, $obj = null)\n"
	"    {\n"
	"        if (is_array($name)) {\n"
	"            $this->bind = array_merge($this->bind, $name);\n"
	"        } else {\n"
	"            $this->bind[$name] = $obj;\n"
	"        }\n"
	"    }\n"
	"\n"
	"    public function __set($name, $value)\n"
	"    {\n"
	"        $this->bind[$name] = $value;\n"
	"    }\n"
	"\n"
	"    public function __get($name)\n"
	"    {\n"
	"        return isset($this->bind[$name]) ? $this->bind[$name] : null;\n"
	"    }\n"
	"\n"
	"    public function __isset($name)\n"
	"    {\n"
	"        return isset($this->bind[$name]);\n"
	"    }\n"
	"}\n"
	"\n"
;
#endif